function generaPass() {
	
	var longitud = 8;
	var mayusculas = 0;
	if (document.formulario.lower.checked==false && document.formulario.numbers.checked==false){
		alert("Al menos una opcion debe seleccionar para generar su clave!");
		document.formulario.contrasenha.value="";
		document.formulario.repcontrasenha.value="";
		document.formulario.pass.value="";
		document.formulario.lower.focus();
		return;
	}
	
	if (document.formulario.lower.checked==true) {
		var minusculas = 1;
	} else {
		var minusculas = 0;
	}

	if (document.formulario.numbers.checked==true) {
		var numeros = 1;
	} else {
		var numeros = 0;
	}
	document.formulario.pass.value=""+RandomPassword(longitud,mayusculas,numeros,minusculas)+"";
	document.formulario.contrasenha.value=document.formulario.pass.value;
	document.formulario.repcontrasenha.value=document.formulario.pass.value;
}
function RandomPassword(Length, Upper, Numbers, Lower){
	
    Upper = typeof(Upper) != 'undefined' ? Upper : true;
    Numbers = typeof(Numbers) != 'undefined' ? Numbers : true;
    Lower = typeof(Lower) != 'undefined' ? Lower : true;
 	
    if (!Upper && !Lower && !Numbers)
        return "";
 
    var Ret = "";
    var Num;
    var Repeat;
 
    Chars = 26 * 2 + 10;    //26 (a-z) + 26 (A-Z) + 10 (0-9)
    //a-z = 97-122
    //A-Z = 65-90
    //0-9 = 48-57
 
    for (i = 1; i <= Length; i++)
    {
        Repeat = false;
 
        Num = Math.floor(Math.random()*Chars);
 
        if (Num < 26)
            if (Lower)
                Ret = Ret + String.fromCharCode(Num + 97);
            else
                Repeat = true;
        else if (Num < 52)
            if (Upper)
                Ret = Ret + String.fromCharCode(Num - 26 + 65);
            else
                Repeat = true;
        else if (Num < 62)
            if (Numbers)
                Ret = Ret + String.fromCharCode(Num - 52 + 48);
            else
                Repeat = true;
 
        if (Repeat)
            i--;
    }
	    return Ret;
}
